#ifndef MAPCTRL_H
#define MAPCTRL_H

#include <QObject>
#include <QTcpSocket>
#include <QStringList>
#include <QPointF>
#include <QTimer>
#include "SimServer/JQChecksum.h"

class MapCtrl : public QObject
{
    Q_OBJECT
public:
    explicit MapCtrl(QObject *parent = 0);

private:
    QTcpSocket* skt;
    QByteArray hexCache;
    QString dataCache;
    QStringList history;
    bool isMoving;
    QString createPack(QString _type, QStringList params);
    void readFromCache();
    void setCarState(bool ismove);
    QVector<QPointF> getLidarInfo(QStringList);

    bool readHexPac();
signals:
    void carPos(QPointF, int);
    void carState(bool);
    void lidarUpdate(QVector<QPointF>);
    void lidarRawUpdate(QVector<QPointF>);
    void carInfo(QStringList);
    void blockInfo(QStringList);
    void carPorpMap(QVariantMap);

public slots:
    void gotoPosReq(QPointF, int index);
    void carCtrlStart();
    void carCtrlStop();
    void mapLoad(QString path);
    void setDriveMode(bool isAutoMode);

private slots:
    void connectStateChanged(QAbstractSocket::SocketState state);
    void reconnect();
    void readData();
};

#endif // MAPCTRL_H
